const http = require('http');
http.createServer((req, res) => {
  // 添加 CORS 响应头
  res.setHeader('Access-Control-Allow-Origin', '*'); 
  res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
  res.setHeader('Access-Control-Allow-Headers', 'Content-Type');

  res.writeHead(200, { 'Content-Type': 'application/json' });
  res.end(JSON.stringify({ from: '本地测试环境', path: req.url }));
}).listen(3000, () => {
  console.log('本地服务运行在 http://localhost:3000，已开启 CORS');
});